package com.zhuizikejithreeig.cn.adapter;

import android.graphics.Color;
import android.os.Build;
import android.view.View;
import android.widget.TextView;

import com.zhuizikejithreeig.cn.been.LanYaBeen;
import com.zhuizikejithreeig.cn.braodcast.Bluetooth;
import com.zhuizikejithreeig.cn.threeigkeji.R;
import com.zhuizikejithreeig.cn.threeigkeji.mianinfo.ControlActivty;

import java.util.List;

public class LaYaListAdapter extends BasicRecycleViewAdapter<LanYaBeen> {

    private Bluetooth bluetooth= ControlActivty.bluetooth;
    private LaYaListAdapter adapter;

    public LaYaListAdapter(List<LanYaBeen> showItems) {
        super(showItems);
        adapter = this;
    }

    @Override
    public void convert(BasicViewholder holder, final LanYaBeen itm, final int position) {
        final TextView textView = (TextView) holder.getView(R.id.textview);
        textView.setText(itm.getName());
        if (itm.getCencent()){
            textView.setTextColor(Color.BLUE);
        }else {
            textView.setTextColor(Color.BLACK);
        }
        holder.getView(R.id.parent).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                textView.setTextColor(Color.BLUE);
                itm.setCencent(true);
                bluetooth.sendUri(itm.getPostion());
                adapter.notifyDataSetChanged();
            }
        });

    }

    @Override
    public int getSuccessFullView(int viewType) {
        return R.layout.lanya;
    }


}
